from zope.interface import implements, Interface

from Products.Five import BrowserView
from Products.CMFCore.utils import getToolByName
from plone.memoize.instance import memoize
from Acquisition import aq_inner

from my315ok.xtjxwcontents import xtjxwcontentsMessageFactory as _
from my315ok.xtjxwcontents.browser.barsview import barsView
from my315ok.xtjxwcontents.browser.recommendtecherview import recommendtecherView
from my315ok.xtjxwcontents.interfaces.jiaolian import Ijiaolian

class IbarsjiaolianView(Interface):
    """
    barsjiaolian view interface
    """

    def test():
        """ test method"""


class barsjiaolianView(recommendtecherView):
    """
    barsjiaolian browser view
    """
    implements(IbarsjiaolianView)

    @memoize
    def fetchimage(self):
        context = aq_inner(self.context)
        catalog = getToolByName(context, 'portal_catalog')
        sepath= '/'.join(context.getPhysicalPath()) 
        query = {'object_provides':Ijiaolian.__identifier__,
                 'sort_on':'modified',
                 'sort_order':'reverse',
                 'path':sepath,
         'level':1,
                 }        
        sd = catalog(query)
        return sd
